﻿using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Forms;
using System.Drawing;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UITest.Extension;
using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;


namespace Emotive.PackageUI.Test
{
    /// <summary>
    /// Summary description for CodedUITest1
    /// </summary>
    [CodedUITest]
    public class PackageUI
    {
        public PackageUI()
        {
        }

        [TestMethod]
        public void OpenPackageSol()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.StartDesigner();
            this.UIMap.LoadPackageSol();
            this.UIMap.ExpandPackSol();
        }

        [TestMethod]
        public void Pack_AddNew()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddNewEmptyPack();
            this.UIMap.ClickOKAddNewPack();
            this.UIMap.CheckNewEmptyPack();
            this.UIMap.AddNewSubEmptyPack();
            this.UIMap.ClickOKAddNewPack();
            this.UIMap.ExpandEmptyPack();
            this.UIMap.CheckNewSubEmptyPack();

        }

        [TestMethod]
        public void Pack_AddNewSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddNewEmptyPack();
            this.UIMap.ClickOKAddNewPack();
            this.UIMap.CheckWarningSamePackName();
            this.UIMap.ClickOKWarningSamePackName();
            this.UIMap.AddNewSubEmptyPack();
            this.UIMap.ClickOKAddNewPack();
            this.UIMap.CheckWarningSamePackName_A();
            this.UIMap.ClickOKWarningSamePackName();
        }

        [TestMethod]
        public void Pack_RenameEmptyPck()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463

            this.UIMap.RenameNewEmptyPack();
            this.UIMap.ClickOKRenamePack();
            this.UIMap.CheckEmptyPack();
            this.UIMap.RenameNewSubEmptyPack();
            this.UIMap.ClickOKRenamePack();
            this.UIMap.CheckSubEmptyPack();
        }

        [TestMethod]
        public void Pack_CopyPasteEmptyPck()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.CopyEmptyPackage();
            this.UIMap.PasteOnP1();            
            this.UIMap.ExpandP1EmptyPack1();
            this.UIMap.CheckEmptyPack1();
            this.UIMap.CheckSubEmptyPack_A();
            this.UIMap.PasteOnP2();
            this.UIMap.ExpandP2EmptyPackage();
            this.UIMap.CheckP2EmptyPack();
            this.UIMap.CheckP2SubEmptyPack();

            this.UIMap.CopyP2SubEmptyPack();
            this.UIMap.PasteOnP1EmptyPack1();
            this.UIMap.CheckP1SubEmptyPack1();
            this.UIMap.PasteOnP2EmptyPack();
            this.UIMap.CheckP2SubEmptyPack1();
        }

        [TestMethod]
        public void Pack_DeleteEmptyPck()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.DeleteP1EmtyPack1();
        }

        [TestMethod]
        public void Pack_CutPasteEmptyPck()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.CutP2EmptyPack();
            this.UIMap.PasteOnP1();
            this.UIMap.CheckEmptyPack1();
            this.UIMap.CheckSubEmptyPack_A();
            this.UIMap.CutP1EmptyPackage();
            this.UIMap.PasteOnP2();
            this.UIMap.CheckP2EmptyPack();
            this.UIMap.CheckP2SubEmptyPack();
        }

        [TestMethod]
        public void Pack_RenamePck()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.RenameNewP1Package1();
            this.UIMap.ClickOKRenamePack();
            this.UIMap.CheckP1_Pack1();
            //this.UIMap.OpenNewP1Pack2ProcMain();
            //this.UIMap.ExecuteCurrentWF();
            this.UIMap.RenameNewP1Pack2();
            this.UIMap.ClickOKRenamePack();
            this.UIMap.CheckP1_Pack2();

        }

        [TestMethod]
        public void Pack_RenameSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.RenameP1_Pack1();
            this.UIMap.CheckWarningSamePackName_B();
            this.UIMap.ClickOKWarningSamePackName();
        }

        [TestMethod]
        public void Pack_CopyPasteWithPckDoc()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.CopyP1_Pack2();
            this.UIMap.PasteOnP2();
            this.UIMap.CheckP1_Pack2_A();
        }

        [TestMethod]
        public void Pack_DeletePckWithDoc()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.DeleteP1_Pack2();
        }

        [TestMethod]
        public void Pack_CutPastePckWithDoc()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.CutP1_Pack2OfP2();
            this.UIMap.PasteOnP1();
            this.UIMap.CheckP1_Pack2();
            this.UIMap.CutP1_Pack2OfP1();
            this.UIMap.PasteOnP2();
            this.UIMap.CheckP1_Pack2_A();
        }

        [TestMethod]
        public void Pack_AddExistingPck()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddP3PackValidation();
            this.UIMap.SelectPackageValidation();
            this.UIMap.CheckPackValidation();
            this.UIMap.AddP3PckVLD_PckVLD();
            this.UIMap.SelectPackageValidation();
            this.UIMap.ExpandPackValidation();
            this.UIMap.CheckPckVLD_PckVLD();
        }

        [TestMethod]
        public void Pack_Validate()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.ValidatePackValidation();
            this.UIMap.CheckErrorNum();
            this.UIMap.CheckWarningNum();
            this.UIMap.ValidatePackValidation_A();
            this.UIMap.CheckErrorNum_A();
            this.UIMap.CheckWarningNum_A();
        }

        [TestMethod]
        public void Pack_AddExistingSameName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddP3PackValidation();
            this.UIMap.SelectPackageValidation();
            this.UIMap.CheckPackValidation1();
        }

        [TestMethod]
        public void Pack_AddNewWrongName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddNewPackWrongName();
            this.UIMap.ClickCancelAddNewPack();
        }

        [TestMethod]
        public void Pack_AddExistingWrongName()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.AddP3PackValidation();
            this.UIMap.SelectExistingPackWrongName();
            this.UIMap.CheckAddExistingPckWrongName();
            this.UIMap.ClickOKWarningAddExistingPckWrongName();
        }

        [TestMethod]
        public void Pack_DeletePdx()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.ExpandP1Reference();
            this.UIMap.DeletePdxPackage1();            
            this.UIMap.DeletePdxPackage2();
        }

        [TestMethod]
        public void Pack_CopyPckFromPdx()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.Pack_CopyPckFromPdx();
            this.UIMap.PasteOnP1();
            this.UIMap.CheckPdxPack1();
            this.UIMap.CopyPdxPackage2();
            this.UIMap.PasteOnP2();
            this.UIMap.CheckPdxPack2();
        }

        [TestMethod]
        public void Pack_CutPckFromPdx()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.Pack_CutPckFromPdx();
            this.UIMap.PasteOnP2();
            this.UIMap.CheckPdxPack1ExistPdx();
        }

        [TestMethod]
        public void Pack_PastePckIntoPdx()
        {
            // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
            // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
            this.UIMap.CopyPackValidation();
            this.UIMap.PasteOnPdx1();
            this.UIMap.PasteOnPdx1NewPdxPack1();

        }

        #region Additional test attributes

        // You can use the following additional attributes as you write your tests:

        ////Use TestInitialize to run code before running each test 
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
        //}

        ////Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{        
        //    // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        //    // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
        //}

        #endregion

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        private TestContext testContextInstance;

        public UIMap UIMap
        {
            get
            {
                if ((this.map == null))
                {
                    this.map = new UIMap();
                }

                return this.map;
            }
        }

        private UIMap map;
    }
}
